
package com.emex.app.stuff.gui.model;

import com.emex.app.shared.data.ProfitType;
import com.emex.app.stuff.provider.ProfitDataProvider;
import java.util.List;
import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;

/**
 *
 * @author Sergey Karavaev
 */
public class ProfitTypeComboBoxModel extends AbstractListModel implements ComboBoxModel {
    
     /**
     * Currently selected car object.
     */
    private ProfitType selection;
    /**
     * Array of providers - needed to implement ComboBoxModel functionality.
     */
    private List<ProfitType> providers;


    public ProfitTypeComboBoxModel() {
        providers = ProfitDataProvider.getInstance().getAllProfitTypes();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void setSelectedItem(Object anItem) {
        selection = (ProfitType) anItem;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Object getSelectedItem() {
        return selection;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public int getSize() {
        return providers.size();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Object getElementAt(int index) {
        return providers.get(index);
    }
}
